feat: add guard variants for mock_stat and mock_all_from_stat#103
Draft
Koan-Bot wants to merge 1 commit intocpan-authors:mainfrom
Draft
feat: add guard variants for mock_stat and mock_all_from_stat#103Koan-Bot wants to merge 1 commit intocpan-authors:mainfrom
Koan-Bot wants to merge 1 commit intocpan-authors:mainfrom
Conversation
…l_from_stat The existing mock_file_check_guard() only covers single-check mocking. Test suites that use mock_stat or mock_all_from_stat (the most common pattern) had no scope-guard option, forcing manual unmock_stat() or unmock_all_file_checks() calls that break test isolation on die/failure. New functions: - mock_stat_guard(CODE) — guards stat/lstat mocks - mock_all_file_checks_guard(CODE) — guards all -X check mocks - mock_all_from_stat_guard(CODE) — guards everything (checks + stat/lstat) All return the existing Overload::FileCheck::Guard object, supporting cancel() and automatic cleanup on scope exit or die. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds scope-guard variants for the three remaining mock functions that lacked them.
Why
mock_file_check_guard()exists but only covers single-check mocking. The most common usage pattern —mock_all_from_stat— had no guard option, forcing manual cleanup calls that break test isolation when tests die or fail early.How
Three new functions, all returning the existing
Overload::FileCheck::Guardobject:mock_stat_guard(CODE)— guards stat/lstat mocksmock_all_file_checks_guard(CODE)— guards all -X check mocksmock_all_from_stat_guard(CODE)— guards everything (checks + stat/lstat)Each captures the set of mocked ops at creation time and unmocks them on scope exit.
Testing
t/guard-variants.twith 9 subtests covering scope cleanup, cancel, die-safety, and sequential guards🤖 Generated with Claude Code
Quality Report
Changes: 2 files changed, 263 insertions(+), 2 deletions(-)
Code scan: clean
Tests: passed (0 Tests)
Branch hygiene: clean
Generated by Kōan post-mission quality pipeline